import { RouteRecordRaw } from "vue-router";
import AdminView from "@/views/AdminView.vue";
import NoAuthView from "@/views/NoAuthView.vue";
import AccessEnum from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import UserLoginOutView from "@/views/user/UserLoginOutView.vue";
import CodeView from "@/views/CodeView.vue";
import AddProblemView from "@/problem/AddProblemView.vue";
import ManageProblemView from "@/problem/ManageProblemView.vue";
import ProblemListView from "@/problem/ProblemListView.vue";
import ViewProblemView from "@/problem/ViewProblemView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "题目列表",
    component: ProblemListView,
  },
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    meta: {
      hideInMenu: true,
    },
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
  },
  {
    path: "/noAuth",
    name: "没有权限",
    component: NoAuthView,
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/admin",
    name: "ADMIN",
    component: AdminView,
    meta: { access: AccessEnum.ADMIN },
  },
  {
    path: "/add/problem",
    name: "创建题目",
    component: AddProblemView,
    meta: { access: AccessEnum.ADMIN },
  },
  {
    path: "/update/problem",
    name: "修改题目",
    component: AddProblemView,
    meta: { hideInMenu: true, access: AccessEnum.USER },
  },
  {
    path: "/view/problem/:id",
    props: true,
    name: "查看题目",
    component: ViewProblemView,
    meta: { hideInMenu: true },
  },
  {
    path: "/manager/problem",
    name: "管理题目",
    component: ManageProblemView,
    meta: { access: AccessEnum.ADMIN },
  },
  {
    path: "/about",
    name: "关于",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
  {
    path: "/code_editor",
    name: "代码编辑器",
    component: CodeView,
  },
  {
    path: "/user/loginOut",
    name: "注销",
    component: UserLoginOutView,
    meta: {
      hideInMenu: true,
    },
  },
];
